package com.gzs.zhdj.mapper;

import com.github.pagehelper.Page;
import com.gzs.zhdj.domain.dto.PartyMemberPageDto;
import com.gzs.zhdj.domain.entity.PartyMember;
import com.gzs.zhdj.domain.dto.PartyMemberDto;
import com.gzs.zhdj.domain.dto.PasswordEditDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    /*

     */
    @Insert("insert into partymemberinfo(id, password, name, party_id, role) values (#{id},#{password},#{name},#{partyId},#{role})")
    void insert(PartyMember partyMember);

    @Select("select * from partymemberinfo where id = #{id}")
    PartyMember getById(int id);

    @Update("update partymemberinfo set password = #{newPassword} where id = #{id}")
    void updatePasswordById(PasswordEditDto passwordEditDto);

    @Update("update partymemberinfo set password = #{newPassword2} where id = #{id}")
    void updatePassword(PasswordEditDto passwordEditDto);

    void update(PartyMember partyMember);

    @Update("update partymemberinfo set image = #{filePath} where id = #{id}")
    void upload(@Param("id") int id, @Param("filePath") String filePath);

    Page<PartyMember> pageQuery(PartyMemberPageDto partyMemberPageDto);

    @Select("select * from partymemberinfo where name = #{name}")
    PartyMember getByName(String name);

    @Update("update partymemberinfo set role = #{role} where name = #{oldName}")
    void updateRole(@Param("oldName") String oldName, @Param("role")String role);

    @Select("select id from partymemberinfo")
    List<Integer> getId();

    void updateInfoById(PartyMember partyMember);

    @Select("select party_id from partymemberinfo where id = #{id}")
    int getOidById(int id);
}
